
import redis
from lib.redis.abstract import RedisAbstract


class RedisClient(RedisAbstract):

    def __init__(self, host, port=6379, auth=None, db=0, decode_responses=False, logger=None):
        super(RedisClient, self).__init__(logger)
        self.client = redis.StrictRedis(host=host, port=port, password=auth, db=db, decode_responses=decode_responses)

    def ping(self):
        return self.client.ping()

    def size(self):
        return self.client.dbsize()

    def ttl(self, name):
        return self.client.ttl(name)

    def expire(self, name, time):
        return self.client.expire(name, time)

    def persist(self, name):
        return self.client.persist(name)

    def type(self, name):
        return self.client.type(name)

    def rename(self, name, new_name):
        return self.client.rename(name, new_name)

    def renamenx(self, name, new_name):
        return self.client.renamenx(name, new_name)

    def keys(self, pattern='*'):
        return self.client.keys(pattern)

    def scan(self, cursor=0, match=None, count=None):
        return self.client.scan(cursor, match, count)

    def exists(self, name):
        return self.client.exists(name)

    def get(self, name):
        return self.client.get(name)

    def set(self, name, value):
        return self.client.set(name, value)

    def getset(self, name, value):
        return self.client.getset(name, value)

    def delete(self, name):
        return self.client.delete(name)

    def hexists(self, name, key):
        return self.client.hexists(name, key)

    def hall(self, name):
        return self.client.hgetall(name)

    def hget(self, name, key):
        return self.client.hget(name, key)

    def hset(self, name, key, value):
        return self.client.hset(name, key, value)

    def hmget(self, name, keys, *args):
        return self.client.hmget(name, keys, args)

    def hmset(self, name, dict):
        return self.client.hmset(name, dict)

    def hdel(self, name, key):
        return self.client.hdel(name, key)

